﻿<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type='text/xsl' href="scriptsql.xsl"?>
<root xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database includeDrop="true">MetropasWeb</database>
<procedures>
		
		<procedure owner="dbo" name="Activity_Get_List" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets all records from the Activity table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				SELECT
					[Id],
					[SessionId],
					[UserId],
					[Ip],
					[DateLogin],
					[DateLogout],
					[Description]
				FROM
					[dbo].[Activity]
					
				SELECT @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="Activity_GetPaged" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Activity table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				DECLARE @SQL AS nvarchar(4000)
				SET @SQL = 'INSERT INTO #PageIndex ([Id])'
				SET @SQL = @SQL + ' SELECT'
				SET @SQL = @SQL + ' [Id]'
				SET @SQL = @SQL + ' FROM [dbo].[Activity]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				IF LEN(@OrderBy) > 0
				BEGIN
					SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				END
				
				-- Only get the number of rows needed here.
				SET ROWCOUNT @PageUpperBound
				
				-- Populate the temp table
				EXEC sp_executesql @SQL

				-- Reset Rowcount back to all
				SET ROWCOUNT 0
				
				-- Return paged results
				SELECT O.[Id], O.[SessionId], O.[UserId], O.[Ip], O.[DateLogin], O.[DateLogout], O.[Description]
				FROM
				    [dbo].[Activity] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > @PageLowerBound
					AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) AS TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[Activity]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				EXEC sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="Activity_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Inserts a record into the Activity table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Output" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@SessionId" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@UserId" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Ip" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@DateLogin" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@DateLogout" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@Description" type="nvarchar" direction="Input" size="150" precision="0" scale="0" param="(150)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				INSERT INTO [dbo].[Activity]
					(
					[SessionId]
					,[UserId]
					,[Ip]
					,[DateLogin]
					,[DateLogout]
					,[Description]
					)
				VALUES
					(
					@SessionId
					,@UserId
					,@Ip
					,@DateLogin
					,@DateLogout
					,@Description
					)
				
				-- Get the identity value
				SET @Id = SCOPE_IDENTITY()
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Activity_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Updates a record in the Activity table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@SessionId" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@UserId" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Ip" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@DateLogin" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@DateLogout" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@Description" type="nvarchar" direction="Input" size="150" precision="0" scale="0" param="(150)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[Activity]
				SET
					[SessionId] = @SessionId
					,[UserId] = @UserId
					,[Ip] = @Ip
					,[DateLogin] = @DateLogin
					,[DateLogout] = @DateLogout
					,[Description] = @Description
				WHERE
[Id] = @Id 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Activity_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Deletes a record in the Activity table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[Activity] WITH (ROWLOCK) 
				WHERE
					[Id] = @Id
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Activity_GetByUserId" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Activity table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@UserId" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				
				SELECT
					[Id],
					[SessionId],
					[UserId],
					[Ip],
					[DateLogin],
					[DateLogout],
					[Description]
				FROM
					[dbo].[Activity]
				WHERE
					[UserId] = @UserId
				
				SELECT @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Activity_GetBySessionId" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Activity table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SessionId" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[SessionId],
					[UserId],
					[Ip],
					[DateLogin],
					[DateLogout],
					[Description]
				FROM
					[dbo].[Activity]
				WHERE
					[SessionId] = @SessionId
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="Activity_GetById" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Activity table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[SessionId],
					[UserId],
					[Ip],
					[DateLogin],
					[DateLogout],
					[Description]
				FROM
					[dbo].[Activity]
				WHERE
					[Id] = @Id
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="Activity_Find" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Finds records in the Activity table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@SessionId" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@UserId" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@Ip" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@DateLogin" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@DateLogout" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@Description" type="nvarchar" direction="Input" size="150" precision="0" scale="0" param="(150)" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [Id]
	, [SessionId]
	, [UserId]
	, [Ip]
	, [DateLogin]
	, [DateLogout]
	, [Description]
    FROM
	[dbo].[Activity]
    WHERE 
	 ([Id] = @Id OR @Id IS NULL)
	AND ([SessionId] = @SessionId OR @SessionId IS NULL)
	AND ([UserId] = @UserId OR @UserId IS NULL)
	AND ([Ip] = @Ip OR @Ip IS NULL)
	AND ([DateLogin] = @DateLogin OR @DateLogin IS NULL)
	AND ([DateLogout] = @DateLogout OR @DateLogout IS NULL)
	AND ([Description] = @Description OR @Description IS NULL)
						
  END
  ELSE
  BEGIN
    SELECT
	  [Id]
	, [SessionId]
	, [UserId]
	, [Ip]
	, [DateLogin]
	, [DateLogout]
	, [Description]
    FROM
	[dbo].[Activity]
    WHERE 
	 ([Id] = @Id AND @Id is not null)
	OR ([SessionId] = @SessionId AND @SessionId is not null)
	OR ([UserId] = @UserId AND @UserId is not null)
	OR ([Ip] = @Ip AND @Ip is not null)
	OR ([DateLogin] = @DateLogin AND @DateLogin is not null)
	OR ([DateLogout] = @DateLogout AND @DateLogout is not null)
	OR ([Description] = @Description AND @Description is not null)
	SELECT @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="Activity_Find_Dynamic"  skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Activity table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				BEGIN
				
				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				INSERT INTO #PageIndex ( [Id] )
				SELECT TOP {3} [Id]
				FROM [dbo].[Activity] {0}
				ORDER BY {1}
				
				-- Return paged results
				SELECT O.[Id], O.[SessionId], O.[UserId], O.[Ip], O.[DateLogin], O.[DateLogout], O.[Description]
				FROM
				    [dbo].[Activity] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > {2}
				    AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				

				-- get total count
				SELECT COUNT(*) AS TotalRowCount FROM [dbo].[Activity] {0};
				
				DROP TABLE #PageIndex
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="Setting_Get_List" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets all records from the Setting table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				SELECT
					[SettingName],
					[SettingValue],
					[DataType],
					[Description]
				FROM
					[dbo].[Setting]
					
				SELECT @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="Setting_GetPaged" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Setting table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [SettingName] nvarchar(50)  
				)
				
				-- Insert into the temp table
				DECLARE @SQL AS nvarchar(4000)
				SET @SQL = 'INSERT INTO #PageIndex ([SettingName])'
				SET @SQL = @SQL + ' SELECT'
				SET @SQL = @SQL + ' [SettingName]'
				SET @SQL = @SQL + ' FROM [dbo].[Setting]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				IF LEN(@OrderBy) > 0
				BEGIN
					SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				END
				
				-- Only get the number of rows needed here.
				SET ROWCOUNT @PageUpperBound
				
				-- Populate the temp table
				EXEC sp_executesql @SQL

				-- Reset Rowcount back to all
				SET ROWCOUNT 0
				
				-- Return paged results
				SELECT O.[SettingName], O.[SettingValue], O.[DataType], O.[Description]
				FROM
				    [dbo].[Setting] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > @PageLowerBound
					AND O.[SettingName] = PageIndex.[SettingName]
				ORDER BY
				    PageIndex.IndexId
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) AS TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[Setting]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				EXEC sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="Setting_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Inserts a record into the Setting table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SettingName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@SettingValue" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@DataType" type="nchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@Description" type="nchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				INSERT INTO [dbo].[Setting]
					(
					[SettingName]
					,[SettingValue]
					,[DataType]
					,[Description]
					)
				VALUES
					(
					@SettingName
					,@SettingValue
					,@DataType
					,@Description
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Setting_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Updates a record in the Setting table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SettingName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@OriginalSettingName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@SettingValue" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@DataType" type="nchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@Description" type="nchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[Setting]
				SET
					[SettingName] = @SettingName
					,[SettingValue] = @SettingValue
					,[DataType] = @DataType
					,[Description] = @Description
				WHERE
[SettingName] = @OriginalSettingName 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Setting_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Deletes a record in the Setting table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SettingName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[Setting] WITH (ROWLOCK) 
				WHERE
					[SettingName] = @SettingName
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Setting_GetBySettingName" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Setting table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SettingName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[SettingName],
					[SettingValue],
					[DataType],
					[Description]
				FROM
					[dbo].[Setting]
				WHERE
					[SettingName] = @SettingName
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="Setting_Find" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Finds records in the Setting table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@SettingName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@SettingValue" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@DataType" type="nchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault="null"/>
				<parameter name="@Description" type="nchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [SettingName]
	, [SettingValue]
	, [DataType]
	, [Description]
    FROM
	[dbo].[Setting]
    WHERE 
	 ([SettingName] = @SettingName OR @SettingName IS NULL)
	AND ([SettingValue] = @SettingValue OR @SettingValue IS NULL)
	AND ([DataType] = @DataType OR @DataType IS NULL)
	AND ([Description] = @Description OR @Description IS NULL)
						
  END
  ELSE
  BEGIN
    SELECT
	  [SettingName]
	, [SettingValue]
	, [DataType]
	, [Description]
    FROM
	[dbo].[Setting]
    WHERE 
	 ([SettingName] = @SettingName AND @SettingName is not null)
	OR ([SettingValue] = @SettingValue AND @SettingValue is not null)
	OR ([DataType] = @DataType AND @DataType is not null)
	OR ([Description] = @Description AND @Description is not null)
	SELECT @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="Setting_Find_Dynamic"  skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Setting table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				BEGIN
				
				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [SettingName] nvarchar(50)  
				)
				
				-- Insert into the temp table
				INSERT INTO #PageIndex ( [SettingName] )
				SELECT TOP {3} [SettingName]
				FROM [dbo].[Setting] {0}
				ORDER BY {1}
				
				-- Return paged results
				SELECT O.[SettingName], O.[SettingValue], O.[DataType], O.[Description]
				FROM
				    [dbo].[Setting] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > {2}
				    AND O.[SettingName] = PageIndex.[SettingName]
				ORDER BY
				    PageIndex.IndexId
				

				-- get total count
				SELECT COUNT(*) AS TotalRowCount FROM [dbo].[Setting] {0};
				
				DROP TABLE #PageIndex
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="SlideType_Get_List" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets all records from the SlideType table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				SELECT
					[Id],
					[Title]
				FROM
					[dbo].[SlideType]
					
				SELECT @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="SlideType_GetPaged" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the SlideType table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				DECLARE @SQL AS nvarchar(4000)
				SET @SQL = 'INSERT INTO #PageIndex ([Id])'
				SET @SQL = @SQL + ' SELECT'
				SET @SQL = @SQL + ' [Id]'
				SET @SQL = @SQL + ' FROM [dbo].[SlideType]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				IF LEN(@OrderBy) > 0
				BEGIN
					SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				END
				
				-- Only get the number of rows needed here.
				SET ROWCOUNT @PageUpperBound
				
				-- Populate the temp table
				EXEC sp_executesql @SQL

				-- Reset Rowcount back to all
				SET ROWCOUNT 0
				
				-- Return paged results
				SELECT O.[Id], O.[Title]
				FROM
				    [dbo].[SlideType] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > @PageLowerBound
					AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) AS TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[SlideType]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				EXEC sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="SlideType_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Inserts a record into the SlideType table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Output" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				INSERT INTO [dbo].[SlideType]
					(
					[Title]
					)
				VALUES
					(
					@Title
					)
				
				-- Get the identity value
				SET @Id = SCOPE_IDENTITY()
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="SlideType_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Updates a record in the SlideType table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[SlideType]
				SET
					[Title] = @Title
				WHERE
[Id] = @Id 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="SlideType_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Deletes a record in the SlideType table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[SlideType] WITH (ROWLOCK) 
				WHERE
					[Id] = @Id
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="SlideType_GetById" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the SlideType table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[Title]
				FROM
					[dbo].[SlideType]
				WHERE
					[Id] = @Id
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="SlideType_Find" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Finds records in the SlideType table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [Id]
	, [Title]
    FROM
	[dbo].[SlideType]
    WHERE 
	 ([Id] = @Id OR @Id IS NULL)
	AND ([Title] = @Title OR @Title IS NULL)
						
  END
  ELSE
  BEGIN
    SELECT
	  [Id]
	, [Title]
    FROM
	[dbo].[SlideType]
    WHERE 
	 ([Id] = @Id AND @Id is not null)
	OR ([Title] = @Title AND @Title is not null)
	SELECT @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="SlideType_Find_Dynamic"  skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the SlideType table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				BEGIN
				
				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				INSERT INTO #PageIndex ( [Id] )
				SELECT TOP {3} [Id]
				FROM [dbo].[SlideType] {0}
				ORDER BY {1}
				
				-- Return paged results
				SELECT O.[Id], O.[Title]
				FROM
				    [dbo].[SlideType] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > {2}
				    AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				

				-- get total count
				SELECT COUNT(*) AS TotalRowCount FROM [dbo].[SlideType] {0};
				
				DROP TABLE #PageIndex
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="UserAccount_Get_List" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets all records from the UserAccount table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				SELECT
					[Id],
					[Username],
					[Title],
					[FirstName],
					[LastName],
					[Password],
					[PasswordSalt],
					[LastLogin],
					[UserType],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser],
					[IsActivity]
				FROM
					[dbo].[UserAccount]
					
				SELECT @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="UserAccount_GetPaged" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the UserAccount table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				DECLARE @SQL AS nvarchar(4000)
				SET @SQL = 'INSERT INTO #PageIndex ([Id])'
				SET @SQL = @SQL + ' SELECT'
				SET @SQL = @SQL + ' [Id]'
				SET @SQL = @SQL + ' FROM [dbo].[UserAccount]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				IF LEN(@OrderBy) > 0
				BEGIN
					SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				END
				
				-- Only get the number of rows needed here.
				SET ROWCOUNT @PageUpperBound
				
				-- Populate the temp table
				EXEC sp_executesql @SQL

				-- Reset Rowcount back to all
				SET ROWCOUNT 0
				
				-- Return paged results
				SELECT O.[Id], O.[Username], O.[Title], O.[FirstName], O.[LastName], O.[Password], O.[PasswordSalt], O.[LastLogin], O.[UserType], O.[CreatedDate], O.[UpdatedDate], O.[CreatedUser], O.[UpdatedUser], O.[IsActivity]
				FROM
				    [dbo].[UserAccount] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > @PageLowerBound
					AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) AS TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[UserAccount]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				EXEC sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="UserAccount_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Inserts a record into the UserAccount table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Output" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Username" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@FirstName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@LastName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Password" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@PasswordSalt" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@LastLogin" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UserType" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@IsActivity" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				INSERT INTO [dbo].[UserAccount]
					(
					[Username]
					,[Title]
					,[FirstName]
					,[LastName]
					,[Password]
					,[PasswordSalt]
					,[LastLogin]
					,[UserType]
					,[CreatedDate]
					,[UpdatedDate]
					,[CreatedUser]
					,[UpdatedUser]
					,[IsActivity]
					)
				VALUES
					(
					@Username
					,@Title
					,@FirstName
					,@LastName
					,@Password
					,@PasswordSalt
					,@LastLogin
					,@UserType
					,@CreatedDate
					,@UpdatedDate
					,@CreatedUser
					,@UpdatedUser
					,@IsActivity
					)
				
				-- Get the identity value
				SET @Id = SCOPE_IDENTITY()
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="UserAccount_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Updates a record in the UserAccount table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Username" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@FirstName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@LastName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Password" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@PasswordSalt" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@LastLogin" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UserType" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@IsActivity" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[UserAccount]
				SET
					[Username] = @Username
					,[Title] = @Title
					,[FirstName] = @FirstName
					,[LastName] = @LastName
					,[Password] = @Password
					,[PasswordSalt] = @PasswordSalt
					,[LastLogin] = @LastLogin
					,[UserType] = @UserType
					,[CreatedDate] = @CreatedDate
					,[UpdatedDate] = @UpdatedDate
					,[CreatedUser] = @CreatedUser
					,[UpdatedUser] = @UpdatedUser
					,[IsActivity] = @IsActivity
				WHERE
[Id] = @Id 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="UserAccount_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Deletes a record in the UserAccount table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[UserAccount] WITH (ROWLOCK) 
				WHERE
					[Id] = @Id
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="UserAccount_GetByUserType" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the UserAccount table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@UserType" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				
				SELECT
					[Id],
					[Username],
					[Title],
					[FirstName],
					[LastName],
					[Password],
					[PasswordSalt],
					[LastLogin],
					[UserType],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser],
					[IsActivity]
				FROM
					[dbo].[UserAccount]
				WHERE
					[UserType] = @UserType
				
				SELECT @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="UserAccount_GetByUsername" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the UserAccount table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Username" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[Username],
					[Title],
					[FirstName],
					[LastName],
					[Password],
					[PasswordSalt],
					[LastLogin],
					[UserType],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser],
					[IsActivity]
				FROM
					[dbo].[UserAccount]
				WHERE
					[Username] = @Username
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="UserAccount_GetById" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the UserAccount table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[Username],
					[Title],
					[FirstName],
					[LastName],
					[Password],
					[PasswordSalt],
					[LastLogin],
					[UserType],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser],
					[IsActivity]
				FROM
					[dbo].[UserAccount]
				WHERE
					[Id] = @Id
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="UserAccount_Find" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Finds records in the UserAccount table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@Username" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault="null"/>
				<parameter name="@FirstName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@LastName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Password" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@PasswordSalt" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@LastLogin" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@UserType" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@IsActivity" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [Id]
	, [Username]
	, [Title]
	, [FirstName]
	, [LastName]
	, [Password]
	, [PasswordSalt]
	, [LastLogin]
	, [UserType]
	, [CreatedDate]
	, [UpdatedDate]
	, [CreatedUser]
	, [UpdatedUser]
	, [IsActivity]
    FROM
	[dbo].[UserAccount]
    WHERE 
	 ([Id] = @Id OR @Id IS NULL)
	AND ([Username] = @Username OR @Username IS NULL)
	AND ([Title] = @Title OR @Title IS NULL)
	AND ([FirstName] = @FirstName OR @FirstName IS NULL)
	AND ([LastName] = @LastName OR @LastName IS NULL)
	AND ([Password] = @Password OR @Password IS NULL)
	AND ([PasswordSalt] = @PasswordSalt OR @PasswordSalt IS NULL)
	AND ([LastLogin] = @LastLogin OR @LastLogin IS NULL)
	AND ([UserType] = @UserType OR @UserType IS NULL)
	AND ([CreatedDate] = @CreatedDate OR @CreatedDate IS NULL)
	AND ([UpdatedDate] = @UpdatedDate OR @UpdatedDate IS NULL)
	AND ([CreatedUser] = @CreatedUser OR @CreatedUser IS NULL)
	AND ([UpdatedUser] = @UpdatedUser OR @UpdatedUser IS NULL)
	AND ([IsActivity] = @IsActivity OR @IsActivity IS NULL)
						
  END
  ELSE
  BEGIN
    SELECT
	  [Id]
	, [Username]
	, [Title]
	, [FirstName]
	, [LastName]
	, [Password]
	, [PasswordSalt]
	, [LastLogin]
	, [UserType]
	, [CreatedDate]
	, [UpdatedDate]
	, [CreatedUser]
	, [UpdatedUser]
	, [IsActivity]
    FROM
	[dbo].[UserAccount]
    WHERE 
	 ([Id] = @Id AND @Id is not null)
	OR ([Username] = @Username AND @Username is not null)
	OR ([Title] = @Title AND @Title is not null)
	OR ([FirstName] = @FirstName AND @FirstName is not null)
	OR ([LastName] = @LastName AND @LastName is not null)
	OR ([Password] = @Password AND @Password is not null)
	OR ([PasswordSalt] = @PasswordSalt AND @PasswordSalt is not null)
	OR ([LastLogin] = @LastLogin AND @LastLogin is not null)
	OR ([UserType] = @UserType AND @UserType is not null)
	OR ([CreatedDate] = @CreatedDate AND @CreatedDate is not null)
	OR ([UpdatedDate] = @UpdatedDate AND @UpdatedDate is not null)
	OR ([CreatedUser] = @CreatedUser AND @CreatedUser is not null)
	OR ([UpdatedUser] = @UpdatedUser AND @UpdatedUser is not null)
	OR ([IsActivity] = @IsActivity AND @IsActivity is not null)
	SELECT @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="UserAccount_Find_Dynamic"  skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the UserAccount table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				BEGIN
				
				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				INSERT INTO #PageIndex ( [Id] )
				SELECT TOP {3} [Id]
				FROM [dbo].[UserAccount] {0}
				ORDER BY {1}
				
				-- Return paged results
				SELECT O.[Id], O.[Username], O.[Title], O.[FirstName], O.[LastName], O.[Password], O.[PasswordSalt], O.[LastLogin], O.[UserType], O.[CreatedDate], O.[UpdatedDate], O.[CreatedUser], O.[UpdatedUser], O.[IsActivity]
				FROM
				    [dbo].[UserAccount] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > {2}
				    AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				

				-- get total count
				SELECT COUNT(*) AS TotalRowCount FROM [dbo].[UserAccount] {0};
				
				DROP TABLE #PageIndex
				END
			]]></body>
		</procedure>
		
				
		<procedure owner="dbo" name="_UserAccount_Login"  skip="true">
			<comment><![CDATA[]]></comment>
			<parameters>
				<parameter name="@UserName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Password" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				
sWord

			]]></body>
					</procedure>
		
		<procedure owner="dbo" name="tblSettings_Get_List" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets all records from the tblSettings table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				SELECT
					[ID],
					[Type],
					[Code],
					[ValueString],
					[ValueBinary]
				FROM
					[dbo].[tblSettings]
					
				SELECT @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tblSettings_GetPaged" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the tblSettings table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [ID] uniqueidentifier 
				)
				
				-- Insert into the temp table
				DECLARE @SQL AS nvarchar(4000)
				SET @SQL = 'INSERT INTO #PageIndex ([ID])'
				SET @SQL = @SQL + ' SELECT'
				SET @SQL = @SQL + ' [ID]'
				SET @SQL = @SQL + ' FROM [dbo].[tblSettings]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				IF LEN(@OrderBy) > 0
				BEGIN
					SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				END
				
				-- Only get the number of rows needed here.
				SET ROWCOUNT @PageUpperBound
				
				-- Populate the temp table
				EXEC sp_executesql @SQL

				-- Reset Rowcount back to all
				SET ROWCOUNT 0
				
				-- Return paged results
				SELECT O.[ID], O.[Type], O.[Code], O.[ValueString], O.[ValueBinary]
				FROM
				    [dbo].[tblSettings] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > @PageLowerBound
					AND O.[ID] = PageIndex.[ID]
				ORDER BY
				    PageIndex.IndexId
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) AS TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tblSettings]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				EXEC sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tblSettings_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Inserts a record into the tblSettings table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="uniqueidentifier" direction="Output" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Type" type="tinyint" direction="Input" size="1" precision="3" scale="0" param="" nulldefault=""/>
				<parameter name="@Code" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@ValueString" type="nvarchar" direction="Input" size="-1" precision="0" scale="0" param="(MAX)" nulldefault=""/>
				<parameter name="@ValueBinary" type="varbinary" direction="Input" size="-1" precision="0" scale="0" param="(MAX)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				INSERT INTO [dbo].[tblSettings]
					(
					[ID]
					,[Type]
					,[Code]
					,[ValueString]
					,[ValueBinary]
					)
				VALUES
					(
					@Id
					,@Type
					,@Code
					,@ValueString
					,@ValueBinary
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tblSettings_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Updates a record in the tblSettings table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalId" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Type" type="tinyint" direction="Input" size="1" precision="3" scale="0" param="" nulldefault=""/>
				<parameter name="@Code" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@ValueString" type="nvarchar" direction="Input" size="-1" precision="0" scale="0" param="(MAX)" nulldefault=""/>
				<parameter name="@ValueBinary" type="varbinary" direction="Input" size="-1" precision="0" scale="0" param="(MAX)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tblSettings]
				SET
					[ID] = @Id
					,[Type] = @Type
					,[Code] = @Code
					,[ValueString] = @ValueString
					,[ValueBinary] = @ValueBinary
				WHERE
[ID] = @OriginalId 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tblSettings_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Deletes a record in the tblSettings table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tblSettings] WITH (ROWLOCK) 
				WHERE
					[ID] = @Id
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tblSettings_GetByCode" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the tblSettings table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Code" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID],
					[Type],
					[Code],
					[ValueString],
					[ValueBinary]
				FROM
					[dbo].[tblSettings]
				WHERE
					[Code] = @Code
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tblSettings_GetById" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the tblSettings table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID],
					[Type],
					[Code],
					[ValueString],
					[ValueBinary]
				FROM
					[dbo].[tblSettings]
				WHERE
					[ID] = @Id
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tblSettings_Find" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Finds records in the tblSettings table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Id" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@Type" type="tinyint" direction="Input" size="1" precision="3" scale="0" param="" nulldefault="null"/>
				<parameter name="@Code" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@ValueString" type="nvarchar" direction="Input" size="-1" precision="0" scale="0" param="(MAX)" nulldefault="null"/>
				<parameter name="@ValueBinary" type="varbinary" direction="Input" size="-1" precision="0" scale="0" param="(MAX)" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID]
	, [Type]
	, [Code]
	, [ValueString]
	, [ValueBinary]
    FROM
	[dbo].[tblSettings]
    WHERE 
	 ([ID] = @Id OR @Id IS NULL)
	AND ([Type] = @Type OR @Type IS NULL)
	AND ([Code] = @Code OR @Code IS NULL)
	AND ([ValueString] = @ValueString OR @ValueString IS NULL)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID]
	, [Type]
	, [Code]
	, [ValueString]
	, [ValueBinary]
    FROM
	[dbo].[tblSettings]
    WHERE 
	 ([ID] = @Id AND @Id is not null)
	OR ([Type] = @Type AND @Type is not null)
	OR ([Code] = @Code AND @Code is not null)
	OR ([ValueString] = @ValueString AND @ValueString is not null)
	SELECT @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tblSettings_Find_Dynamic"  skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the tblSettings table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				BEGIN
				
				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [ID] uniqueidentifier 
				)
				
				-- Insert into the temp table
				INSERT INTO #PageIndex ( [ID] )
				SELECT TOP {3} [ID]
				FROM [dbo].[tblSettings] {0}
				ORDER BY {1}
				
				-- Return paged results
				SELECT O.[ID], O.[Type], O.[Code], O.[ValueString], O.[ValueBinary]
				FROM
				    [dbo].[tblSettings] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > {2}
				    AND O.[ID] = PageIndex.[ID]
				ORDER BY
				    PageIndex.IndexId
				

				-- get total count
				SELECT COUNT(*) AS TotalRowCount FROM [dbo].[tblSettings] {0};
				
				DROP TABLE #PageIndex
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="MessageConfig_Get_List" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets all records from the MessageConfig table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				SELECT
					[KeyCode],
					[Language],
					[Value],
					[TypeId],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser]
				FROM
					[dbo].[MessageConfig]
					
				SELECT @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="MessageConfig_GetPaged" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the MessageConfig table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [KeyCode] varchar(15) , [Language] varchar(10)  
				)
				
				-- Insert into the temp table
				DECLARE @SQL AS nvarchar(4000)
				SET @SQL = 'INSERT INTO #PageIndex ([KeyCode], [Language])'
				SET @SQL = @SQL + ' SELECT'
				SET @SQL = @SQL + ' [KeyCode], [Language]'
				SET @SQL = @SQL + ' FROM [dbo].[MessageConfig]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				IF LEN(@OrderBy) > 0
				BEGIN
					SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				END
				
				-- Only get the number of rows needed here.
				SET ROWCOUNT @PageUpperBound
				
				-- Populate the temp table
				EXEC sp_executesql @SQL

				-- Reset Rowcount back to all
				SET ROWCOUNT 0
				
				-- Return paged results
				SELECT O.[KeyCode], O.[Language], O.[Value], O.[TypeId], O.[CreatedDate], O.[UpdatedDate], O.[CreatedUser], O.[UpdatedUser]
				FROM
				    [dbo].[MessageConfig] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > @PageLowerBound
					AND O.[KeyCode] = PageIndex.[KeyCode]
					AND O.[Language] = PageIndex.[Language]
				ORDER BY
				    PageIndex.IndexId
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) AS TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[MessageConfig]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				EXEC sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="MessageConfig_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Inserts a record into the MessageConfig table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@KeyCode" type="varchar" direction="Input" size="15" precision="0" scale="0" param="(15)" nulldefault=""/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@Value" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@TypeId" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				INSERT INTO [dbo].[MessageConfig]
					(
					[KeyCode]
					,[Language]
					,[Value]
					,[TypeId]
					,[CreatedDate]
					,[UpdatedDate]
					,[CreatedUser]
					,[UpdatedUser]
					)
				VALUES
					(
					@KeyCode
					,@Language
					,@Value
					,@TypeId
					,@CreatedDate
					,@UpdatedDate
					,@CreatedUser
					,@UpdatedUser
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="MessageConfig_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Updates a record in the MessageConfig table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@KeyCode" type="varchar" direction="Input" size="15" precision="0" scale="0" param="(15)" nulldefault=""/>
				<parameter name="@OriginalKeyCode" type="varchar" direction="Input" size="15" precision="0" scale="0" param="(15)" nulldefault=""/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@OriginalLanguage" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@Value" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@TypeId" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[MessageConfig]
				SET
					[KeyCode] = @KeyCode
					,[Language] = @Language
					,[Value] = @Value
					,[TypeId] = @TypeId
					,[CreatedDate] = @CreatedDate
					,[UpdatedDate] = @UpdatedDate
					,[CreatedUser] = @CreatedUser
					,[UpdatedUser] = @UpdatedUser
				WHERE
[KeyCode] = @OriginalKeyCode 
AND [Language] = @OriginalLanguage 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="MessageConfig_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Deletes a record in the MessageConfig table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@KeyCode" type="varchar" direction="Input" size="15" precision="0" scale="0" param="(15)" nulldefault=""/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[MessageConfig] WITH (ROWLOCK) 
				WHERE
					[KeyCode] = @KeyCode
					AND [Language] = @Language
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="MessageConfig_GetByKeyCodeLanguage" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the MessageConfig table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@KeyCode" type="varchar" direction="Input" size="15" precision="0" scale="0" param="(15)" nulldefault=""/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[KeyCode],
					[Language],
					[Value],
					[TypeId],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser]
				FROM
					[dbo].[MessageConfig]
				WHERE
					[KeyCode] = @KeyCode
					AND [Language] = @Language
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="MessageConfig_Find" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Finds records in the MessageConfig table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@KeyCode" type="varchar" direction="Input" size="15" precision="0" scale="0" param="(15)" nulldefault="null"/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault="null"/>
				<parameter name="@Value" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@TypeId" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [KeyCode]
	, [Language]
	, [Value]
	, [TypeId]
	, [CreatedDate]
	, [UpdatedDate]
	, [CreatedUser]
	, [UpdatedUser]
    FROM
	[dbo].[MessageConfig]
    WHERE 
	 ([KeyCode] = @KeyCode OR @KeyCode IS NULL)
	AND ([Language] = @Language OR @Language IS NULL)
	AND ([Value] = @Value OR @Value IS NULL)
	AND ([TypeId] = @TypeId OR @TypeId IS NULL)
	AND ([CreatedDate] = @CreatedDate OR @CreatedDate IS NULL)
	AND ([UpdatedDate] = @UpdatedDate OR @UpdatedDate IS NULL)
	AND ([CreatedUser] = @CreatedUser OR @CreatedUser IS NULL)
	AND ([UpdatedUser] = @UpdatedUser OR @UpdatedUser IS NULL)
						
  END
  ELSE
  BEGIN
    SELECT
	  [KeyCode]
	, [Language]
	, [Value]
	, [TypeId]
	, [CreatedDate]
	, [UpdatedDate]
	, [CreatedUser]
	, [UpdatedUser]
    FROM
	[dbo].[MessageConfig]
    WHERE 
	 ([KeyCode] = @KeyCode AND @KeyCode is not null)
	OR ([Language] = @Language AND @Language is not null)
	OR ([Value] = @Value AND @Value is not null)
	OR ([TypeId] = @TypeId AND @TypeId is not null)
	OR ([CreatedDate] = @CreatedDate AND @CreatedDate is not null)
	OR ([UpdatedDate] = @UpdatedDate AND @UpdatedDate is not null)
	OR ([CreatedUser] = @CreatedUser AND @CreatedUser is not null)
	OR ([UpdatedUser] = @UpdatedUser AND @UpdatedUser is not null)
	SELECT @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="MessageConfig_Find_Dynamic"  skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the MessageConfig table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				BEGIN
				
				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [KeyCode] varchar(15) , [Language] varchar(10)  
				)
				
				-- Insert into the temp table
				INSERT INTO #PageIndex ( [KeyCode], [Language] )
				SELECT TOP {3} [KeyCode], [Language]
				FROM [dbo].[MessageConfig] {0}
				ORDER BY {1}
				
				-- Return paged results
				SELECT O.[KeyCode], O.[Language], O.[Value], O.[TypeId], O.[CreatedDate], O.[UpdatedDate], O.[CreatedUser], O.[UpdatedUser]
				FROM
				    [dbo].[MessageConfig] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > {2}
				    AND O.[KeyCode] = PageIndex.[KeyCode]
				    AND O.[Language] = PageIndex.[Language]
				ORDER BY
				    PageIndex.IndexId
				

				-- get total count
				SELECT COUNT(*) AS TotalRowCount FROM [dbo].[MessageConfig] {0};
				
				DROP TABLE #PageIndex
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="Slide_Get_List" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets all records from the Slide table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				SELECT
					[Id],
					[Url],
					[Title],
					[DataType],
					[Description],
					[Thumbnail],
					[OrderIndex],
					[Language]
				FROM
					[dbo].[Slide]
					
				SELECT @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="Slide_GetPaged" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Slide table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				DECLARE @SQL AS nvarchar(4000)
				SET @SQL = 'INSERT INTO #PageIndex ([Id])'
				SET @SQL = @SQL + ' SELECT'
				SET @SQL = @SQL + ' [Id]'
				SET @SQL = @SQL + ' FROM [dbo].[Slide]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				IF LEN(@OrderBy) > 0
				BEGIN
					SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				END
				
				-- Only get the number of rows needed here.
				SET ROWCOUNT @PageUpperBound
				
				-- Populate the temp table
				EXEC sp_executesql @SQL

				-- Reset Rowcount back to all
				SET ROWCOUNT 0
				
				-- Return paged results
				SELECT O.[Id], O.[Url], O.[Title], O.[DataType], O.[Description], O.[Thumbnail], O.[OrderIndex], O.[Language]
				FROM
				    [dbo].[Slide] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > @PageLowerBound
					AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) AS TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[Slide]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				EXEC sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="Slide_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Inserts a record into the Slide table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Output" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Url" type="nvarchar" direction="Input" size="150" precision="0" scale="0" param="(150)" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="150" precision="0" scale="0" param="(150)" nulldefault=""/>
				<parameter name="@DataType" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Description" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault=""/>
				<parameter name="@Thumbnail" type="varchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				INSERT INTO [dbo].[Slide]
					(
					[Url]
					,[Title]
					,[DataType]
					,[Description]
					,[Thumbnail]
					,[OrderIndex]
					,[Language]
					)
				VALUES
					(
					@Url
					,@Title
					,@DataType
					,@Description
					,@Thumbnail
					,@OrderIndex
					,@Language
					)
				
				-- Get the identity value
				SET @Id = SCOPE_IDENTITY()
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Slide_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Updates a record in the Slide table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Url" type="nvarchar" direction="Input" size="150" precision="0" scale="0" param="(150)" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="150" precision="0" scale="0" param="(150)" nulldefault=""/>
				<parameter name="@DataType" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Description" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault=""/>
				<parameter name="@Thumbnail" type="varchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[Slide]
				SET
					[Url] = @Url
					,[Title] = @Title
					,[DataType] = @DataType
					,[Description] = @Description
					,[Thumbnail] = @Thumbnail
					,[OrderIndex] = @OrderIndex
					,[Language] = @Language
				WHERE
[Id] = @Id 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Slide_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Deletes a record in the Slide table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[Slide] WITH (ROWLOCK) 
				WHERE
					[Id] = @Id
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Slide_GetByDataType" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Slide table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@DataType" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				
				SELECT
					[Id],
					[Url],
					[Title],
					[DataType],
					[Description],
					[Thumbnail],
					[OrderIndex],
					[Language]
				FROM
					[dbo].[Slide]
				WHERE
					[DataType] = @DataType
				
				SELECT @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Slide_GetById" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Slide table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[Url],
					[Title],
					[DataType],
					[Description],
					[Thumbnail],
					[OrderIndex],
					[Language]
				FROM
					[dbo].[Slide]
				WHERE
					[Id] = @Id
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="Slide_Find" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Finds records in the Slide table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@Url" type="nvarchar" direction="Input" size="150" precision="0" scale="0" param="(150)" nulldefault="null"/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="150" precision="0" scale="0" param="(150)" nulldefault="null"/>
				<parameter name="@DataType" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@Description" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault="null"/>
				<parameter name="@Thumbnail" type="varchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [Id]
	, [Url]
	, [Title]
	, [DataType]
	, [Description]
	, [Thumbnail]
	, [OrderIndex]
	, [Language]
    FROM
	[dbo].[Slide]
    WHERE 
	 ([Id] = @Id OR @Id IS NULL)
	AND ([Url] = @Url OR @Url IS NULL)
	AND ([Title] = @Title OR @Title IS NULL)
	AND ([DataType] = @DataType OR @DataType IS NULL)
	AND ([Description] = @Description OR @Description IS NULL)
	AND ([Thumbnail] = @Thumbnail OR @Thumbnail IS NULL)
	AND ([OrderIndex] = @OrderIndex OR @OrderIndex IS NULL)
	AND ([Language] = @Language OR @Language IS NULL)
						
  END
  ELSE
  BEGIN
    SELECT
	  [Id]
	, [Url]
	, [Title]
	, [DataType]
	, [Description]
	, [Thumbnail]
	, [OrderIndex]
	, [Language]
    FROM
	[dbo].[Slide]
    WHERE 
	 ([Id] = @Id AND @Id is not null)
	OR ([Url] = @Url AND @Url is not null)
	OR ([Title] = @Title AND @Title is not null)
	OR ([DataType] = @DataType AND @DataType is not null)
	OR ([Description] = @Description AND @Description is not null)
	OR ([Thumbnail] = @Thumbnail AND @Thumbnail is not null)
	OR ([OrderIndex] = @OrderIndex AND @OrderIndex is not null)
	OR ([Language] = @Language AND @Language is not null)
	SELECT @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="Slide_Find_Dynamic"  skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Slide table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				BEGIN
				
				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				INSERT INTO #PageIndex ( [Id] )
				SELECT TOP {3} [Id]
				FROM [dbo].[Slide] {0}
				ORDER BY {1}
				
				-- Return paged results
				SELECT O.[Id], O.[Url], O.[Title], O.[DataType], O.[Description], O.[Thumbnail], O.[OrderIndex], O.[Language]
				FROM
				    [dbo].[Slide] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > {2}
				    AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				

				-- get total count
				SELECT COUNT(*) AS TotalRowCount FROM [dbo].[Slide] {0};
				
				DROP TABLE #PageIndex
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="Menu_Get_List" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets all records from the Menu table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				SELECT
					[Id],
					[Title],
					[Alias],
					[Link],
					[ParentId],
					[OrderIndex],
					[IsVisible],
					[MenuType],
					[MenuPosition],
					[Language],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser]
				FROM
					[dbo].[Menu]
					
				SELECT @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="Menu_GetPaged" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Menu table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				DECLARE @SQL AS nvarchar(4000)
				SET @SQL = 'INSERT INTO #PageIndex ([Id])'
				SET @SQL = @SQL + ' SELECT'
				SET @SQL = @SQL + ' [Id]'
				SET @SQL = @SQL + ' FROM [dbo].[Menu]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				IF LEN(@OrderBy) > 0
				BEGIN
					SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				END
				
				-- Only get the number of rows needed here.
				SET ROWCOUNT @PageUpperBound
				
				-- Populate the temp table
				EXEC sp_executesql @SQL

				-- Reset Rowcount back to all
				SET ROWCOUNT 0
				
				-- Return paged results
				SELECT O.[Id], O.[Title], O.[Alias], O.[Link], O.[ParentId], O.[OrderIndex], O.[IsVisible], O.[MenuType], O.[MenuPosition], O.[Language], O.[CreatedDate], O.[UpdatedDate], O.[CreatedUser], O.[UpdatedUser]
				FROM
				    [dbo].[Menu] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > @PageLowerBound
					AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) AS TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[Menu]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				EXEC sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="Menu_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Inserts a record into the Menu table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Output" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@Alias" type="varchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@Link" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@ParentId" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@IsVisible" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@MenuType" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@MenuPosition" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				INSERT INTO [dbo].[Menu]
					(
					[Title]
					,[Alias]
					,[Link]
					,[ParentId]
					,[OrderIndex]
					,[IsVisible]
					,[MenuType]
					,[MenuPosition]
					,[Language]
					,[CreatedDate]
					,[UpdatedDate]
					,[CreatedUser]
					,[UpdatedUser]
					)
				VALUES
					(
					@Title
					,@Alias
					,@Link
					,@ParentId
					,@OrderIndex
					,@IsVisible
					,@MenuType
					,@MenuPosition
					,@Language
					,@CreatedDate
					,@UpdatedDate
					,@CreatedUser
					,@UpdatedUser
					)
				
				-- Get the identity value
				SET @Id = SCOPE_IDENTITY()
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Menu_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Updates a record in the Menu table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@Alias" type="varchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@Link" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@ParentId" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@IsVisible" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@MenuType" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@MenuPosition" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[Menu]
				SET
					[Title] = @Title
					,[Alias] = @Alias
					,[Link] = @Link
					,[ParentId] = @ParentId
					,[OrderIndex] = @OrderIndex
					,[IsVisible] = @IsVisible
					,[MenuType] = @MenuType
					,[MenuPosition] = @MenuPosition
					,[Language] = @Language
					,[CreatedDate] = @CreatedDate
					,[UpdatedDate] = @UpdatedDate
					,[CreatedUser] = @CreatedUser
					,[UpdatedUser] = @UpdatedUser
				WHERE
[Id] = @Id 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Menu_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Deletes a record in the Menu table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[Menu] WITH (ROWLOCK) 
				WHERE
					[Id] = @Id
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Menu_GetByAlias" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Menu table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Alias" type="varchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[Title],
					[Alias],
					[Link],
					[ParentId],
					[OrderIndex],
					[IsVisible],
					[MenuType],
					[MenuPosition],
					[Language],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser]
				FROM
					[dbo].[Menu]
				WHERE
					[Alias] = @Alias
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="Menu_GetById" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Menu table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[Title],
					[Alias],
					[Link],
					[ParentId],
					[OrderIndex],
					[IsVisible],
					[MenuType],
					[MenuPosition],
					[Language],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser]
				FROM
					[dbo].[Menu]
				WHERE
					[Id] = @Id
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="Menu_Find" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Finds records in the Menu table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@Alias" type="varchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@Link" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@ParentId" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@IsVisible" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@MenuType" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault="null"/>
				<parameter name="@MenuPosition" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault="null"/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault="null"/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [Id]
	, [Title]
	, [Alias]
	, [Link]
	, [ParentId]
	, [OrderIndex]
	, [IsVisible]
	, [MenuType]
	, [MenuPosition]
	, [Language]
	, [CreatedDate]
	, [UpdatedDate]
	, [CreatedUser]
	, [UpdatedUser]
    FROM
	[dbo].[Menu]
    WHERE 
	 ([Id] = @Id OR @Id IS NULL)
	AND ([Title] = @Title OR @Title IS NULL)
	AND ([Alias] = @Alias OR @Alias IS NULL)
	AND ([Link] = @Link OR @Link IS NULL)
	AND ([ParentId] = @ParentId OR @ParentId IS NULL)
	AND ([OrderIndex] = @OrderIndex OR @OrderIndex IS NULL)
	AND ([IsVisible] = @IsVisible OR @IsVisible IS NULL)
	AND ([MenuType] = @MenuType OR @MenuType IS NULL)
	AND ([MenuPosition] = @MenuPosition OR @MenuPosition IS NULL)
	AND ([Language] = @Language OR @Language IS NULL)
	AND ([CreatedDate] = @CreatedDate OR @CreatedDate IS NULL)
	AND ([UpdatedDate] = @UpdatedDate OR @UpdatedDate IS NULL)
	AND ([CreatedUser] = @CreatedUser OR @CreatedUser IS NULL)
	AND ([UpdatedUser] = @UpdatedUser OR @UpdatedUser IS NULL)
						
  END
  ELSE
  BEGIN
    SELECT
	  [Id]
	, [Title]
	, [Alias]
	, [Link]
	, [ParentId]
	, [OrderIndex]
	, [IsVisible]
	, [MenuType]
	, [MenuPosition]
	, [Language]
	, [CreatedDate]
	, [UpdatedDate]
	, [CreatedUser]
	, [UpdatedUser]
    FROM
	[dbo].[Menu]
    WHERE 
	 ([Id] = @Id AND @Id is not null)
	OR ([Title] = @Title AND @Title is not null)
	OR ([Alias] = @Alias AND @Alias is not null)
	OR ([Link] = @Link AND @Link is not null)
	OR ([ParentId] = @ParentId AND @ParentId is not null)
	OR ([OrderIndex] = @OrderIndex AND @OrderIndex is not null)
	OR ([IsVisible] = @IsVisible AND @IsVisible is not null)
	OR ([MenuType] = @MenuType AND @MenuType is not null)
	OR ([MenuPosition] = @MenuPosition AND @MenuPosition is not null)
	OR ([Language] = @Language AND @Language is not null)
	OR ([CreatedDate] = @CreatedDate AND @CreatedDate is not null)
	OR ([UpdatedDate] = @UpdatedDate AND @UpdatedDate is not null)
	OR ([CreatedUser] = @CreatedUser AND @CreatedUser is not null)
	OR ([UpdatedUser] = @UpdatedUser AND @UpdatedUser is not null)
	SELECT @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="Menu_Find_Dynamic"  skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Menu table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				BEGIN
				
				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				INSERT INTO #PageIndex ( [Id] )
				SELECT TOP {3} [Id]
				FROM [dbo].[Menu] {0}
				ORDER BY {1}
				
				-- Return paged results
				SELECT O.[Id], O.[Title], O.[Alias], O.[Link], O.[ParentId], O.[OrderIndex], O.[IsVisible], O.[MenuType], O.[MenuPosition], O.[Language], O.[CreatedDate], O.[UpdatedDate], O.[CreatedUser], O.[UpdatedUser]
				FROM
				    [dbo].[Menu] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > {2}
				    AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				

				-- get total count
				SELECT COUNT(*) AS TotalRowCount FROM [dbo].[Menu] {0};
				
				DROP TABLE #PageIndex
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="Hospital_Get_List" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets all records from the Hospital table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				SELECT
					[Id],
					[LocalId],
					[Title],
					[Alias],
					[Introduction],
					[Thumbnail],
					[ClinicTime],
					[Contact],
					[Price],
					[Process],
					[OrderIndex],
					[IsVisible],
					[Language],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser]
				FROM
					[dbo].[Hospital]
					
				SELECT @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="Hospital_GetPaged" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Hospital table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				DECLARE @SQL AS nvarchar(4000)
				SET @SQL = 'INSERT INTO #PageIndex ([Id])'
				SET @SQL = @SQL + ' SELECT'
				SET @SQL = @SQL + ' [Id]'
				SET @SQL = @SQL + ' FROM [dbo].[Hospital]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				IF LEN(@OrderBy) > 0
				BEGIN
					SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				END
				
				-- Only get the number of rows needed here.
				SET ROWCOUNT @PageUpperBound
				
				-- Populate the temp table
				EXEC sp_executesql @SQL

				-- Reset Rowcount back to all
				SET ROWCOUNT 0
				
				-- Return paged results
				SELECT O.[Id], O.[LocalId], O.[Title], O.[Alias], O.[Introduction], O.[Thumbnail], O.[ClinicTime], O.[Contact], O.[Price], O.[Process], O.[OrderIndex], O.[IsVisible], O.[Language], O.[CreatedDate], O.[UpdatedDate], O.[CreatedUser], O.[UpdatedUser]
				FROM
				    [dbo].[Hospital] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > @PageLowerBound
					AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) AS TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[Hospital]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				EXEC sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="Hospital_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Inserts a record into the Hospital table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Output" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@LocalId" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Alias" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Introduction" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Thumbnail" type="varchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@ClinicTime" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Contact" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Price" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Process" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@IsVisible" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				INSERT INTO [dbo].[Hospital]
					(
					[LocalId]
					,[Title]
					,[Alias]
					,[Introduction]
					,[Thumbnail]
					,[ClinicTime]
					,[Contact]
					,[Price]
					,[Process]
					,[OrderIndex]
					,[IsVisible]
					,[Language]
					,[CreatedDate]
					,[UpdatedDate]
					,[CreatedUser]
					,[UpdatedUser]
					)
				VALUES
					(
					@LocalId
					,@Title
					,@Alias
					,@Introduction
					,@Thumbnail
					,@ClinicTime
					,@Contact
					,@Price
					,@Process
					,@OrderIndex
					,@IsVisible
					,@Language
					,@CreatedDate
					,@UpdatedDate
					,@CreatedUser
					,@UpdatedUser
					)
				
				-- Get the identity value
				SET @Id = SCOPE_IDENTITY()
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Hospital_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Updates a record in the Hospital table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@LocalId" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Alias" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Introduction" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Thumbnail" type="varchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@ClinicTime" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Contact" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Price" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Process" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@IsVisible" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[Hospital]
				SET
					[LocalId] = @LocalId
					,[Title] = @Title
					,[Alias] = @Alias
					,[Introduction] = @Introduction
					,[Thumbnail] = @Thumbnail
					,[ClinicTime] = @ClinicTime
					,[Contact] = @Contact
					,[Price] = @Price
					,[Process] = @Process
					,[OrderIndex] = @OrderIndex
					,[IsVisible] = @IsVisible
					,[Language] = @Language
					,[CreatedDate] = @CreatedDate
					,[UpdatedDate] = @UpdatedDate
					,[CreatedUser] = @CreatedUser
					,[UpdatedUser] = @UpdatedUser
				WHERE
[Id] = @Id 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Hospital_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Deletes a record in the Hospital table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[Hospital] WITH (ROWLOCK) 
				WHERE
					[Id] = @Id
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Hospital_GetByAlias" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Hospital table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Alias" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[LocalId],
					[Title],
					[Alias],
					[Introduction],
					[Thumbnail],
					[ClinicTime],
					[Contact],
					[Price],
					[Process],
					[OrderIndex],
					[IsVisible],
					[Language],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser]
				FROM
					[dbo].[Hospital]
				WHERE
					[Alias] = @Alias
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="Hospital_GetByLocalId" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Hospital table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@LocalId" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[LocalId],
					[Title],
					[Alias],
					[Introduction],
					[Thumbnail],
					[ClinicTime],
					[Contact],
					[Price],
					[Process],
					[OrderIndex],
					[IsVisible],
					[Language],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser]
				FROM
					[dbo].[Hospital]
				WHERE
					[LocalId] = @LocalId
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="Hospital_GetById" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Hospital table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[LocalId],
					[Title],
					[Alias],
					[Introduction],
					[Thumbnail],
					[ClinicTime],
					[Contact],
					[Price],
					[Process],
					[OrderIndex],
					[IsVisible],
					[Language],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser]
				FROM
					[dbo].[Hospital]
				WHERE
					[Id] = @Id
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="Hospital_Find" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Finds records in the Hospital table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@LocalId" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault="null"/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Alias" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Introduction" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@Thumbnail" type="varchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@ClinicTime" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@Contact" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@Price" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@Process" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@IsVisible" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault="null"/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [Id]
	, [LocalId]
	, [Title]
	, [Alias]
	, [Introduction]
	, [Thumbnail]
	, [ClinicTime]
	, [Contact]
	, [Price]
	, [Process]
	, [OrderIndex]
	, [IsVisible]
	, [Language]
	, [CreatedDate]
	, [UpdatedDate]
	, [CreatedUser]
	, [UpdatedUser]
    FROM
	[dbo].[Hospital]
    WHERE 
	 ([Id] = @Id OR @Id IS NULL)
	AND ([LocalId] = @LocalId OR @LocalId IS NULL)
	AND ([Title] = @Title OR @Title IS NULL)
	AND ([Alias] = @Alias OR @Alias IS NULL)
	AND ([Thumbnail] = @Thumbnail OR @Thumbnail IS NULL)
	AND ([OrderIndex] = @OrderIndex OR @OrderIndex IS NULL)
	AND ([IsVisible] = @IsVisible OR @IsVisible IS NULL)
	AND ([Language] = @Language OR @Language IS NULL)
	AND ([CreatedDate] = @CreatedDate OR @CreatedDate IS NULL)
	AND ([UpdatedDate] = @UpdatedDate OR @UpdatedDate IS NULL)
	AND ([CreatedUser] = @CreatedUser OR @CreatedUser IS NULL)
	AND ([UpdatedUser] = @UpdatedUser OR @UpdatedUser IS NULL)
						
  END
  ELSE
  BEGIN
    SELECT
	  [Id]
	, [LocalId]
	, [Title]
	, [Alias]
	, [Introduction]
	, [Thumbnail]
	, [ClinicTime]
	, [Contact]
	, [Price]
	, [Process]
	, [OrderIndex]
	, [IsVisible]
	, [Language]
	, [CreatedDate]
	, [UpdatedDate]
	, [CreatedUser]
	, [UpdatedUser]
    FROM
	[dbo].[Hospital]
    WHERE 
	 ([Id] = @Id AND @Id is not null)
	OR ([LocalId] = @LocalId AND @LocalId is not null)
	OR ([Title] = @Title AND @Title is not null)
	OR ([Alias] = @Alias AND @Alias is not null)
	OR ([Thumbnail] = @Thumbnail AND @Thumbnail is not null)
	OR ([OrderIndex] = @OrderIndex AND @OrderIndex is not null)
	OR ([IsVisible] = @IsVisible AND @IsVisible is not null)
	OR ([Language] = @Language AND @Language is not null)
	OR ([CreatedDate] = @CreatedDate AND @CreatedDate is not null)
	OR ([UpdatedDate] = @UpdatedDate AND @UpdatedDate is not null)
	OR ([CreatedUser] = @CreatedUser AND @CreatedUser is not null)
	OR ([UpdatedUser] = @UpdatedUser AND @UpdatedUser is not null)
	SELECT @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="Hospital_Find_Dynamic"  skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Hospital table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				BEGIN
				
				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				INSERT INTO #PageIndex ( [Id] )
				SELECT TOP {3} [Id]
				FROM [dbo].[Hospital] {0}
				ORDER BY {1}
				
				-- Return paged results
				SELECT O.[Id], O.[LocalId], O.[Title], O.[Alias], O.[Introduction], O.[Thumbnail], O.[ClinicTime], O.[Contact], O.[Price], O.[Process], O.[OrderIndex], O.[IsVisible], O.[Language], O.[CreatedDate], O.[UpdatedDate], O.[CreatedUser], O.[UpdatedUser]
				FROM
				    [dbo].[Hospital] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > {2}
				    AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				

				-- get total count
				SELECT COUNT(*) AS TotalRowCount FROM [dbo].[Hospital] {0};
				
				DROP TABLE #PageIndex
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="Appointment_Get_List" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets all records from the Appointment table
-- Table Comment: Đặt lịch hẹn
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				SELECT
					[Id],
					[LocalId],
					[FirstName],
					[LastName],
					[FromTime],
					[EndTime],
					[Description],
					[Doctor],
					[ParentId],
					[AppointmentType],
					[CreatedDate]
				FROM
					[dbo].[Appointment]
					
				SELECT @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="Appointment_GetPaged" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Appointment table passing page index and page count parameters
-- Table Comment: Đặt lịch hẹn
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				DECLARE @SQL AS nvarchar(4000)
				SET @SQL = 'INSERT INTO #PageIndex ([Id])'
				SET @SQL = @SQL + ' SELECT'
				SET @SQL = @SQL + ' [Id]'
				SET @SQL = @SQL + ' FROM [dbo].[Appointment]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				IF LEN(@OrderBy) > 0
				BEGIN
					SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				END
				
				-- Only get the number of rows needed here.
				SET ROWCOUNT @PageUpperBound
				
				-- Populate the temp table
				EXEC sp_executesql @SQL

				-- Reset Rowcount back to all
				SET ROWCOUNT 0
				
				-- Return paged results
				SELECT O.[Id], O.[LocalId], O.[FirstName], O.[LastName], O.[FromTime], O.[EndTime], O.[Description], O.[Doctor], O.[ParentId], O.[AppointmentType], O.[CreatedDate]
				FROM
				    [dbo].[Appointment] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > @PageLowerBound
					AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) AS TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[Appointment]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				EXEC sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="Appointment_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Inserts a record into the Appointment table
-- Table Comment: Đặt lịch hẹn
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Output" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@LocalId" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@FirstName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@LastName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@FromTime" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@EndTime" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@Description" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault=""/>
				<parameter name="@Doctor" type="nvarchar" direction="Input" size="100" precision="0" scale="0" param="(100)" nulldefault=""/>
				<parameter name="@ParentId" type="varchar" direction="Input" size="15" precision="0" scale="0" param="(15)" nulldefault=""/>
				<parameter name="@AppointmentType" type="varchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				INSERT INTO [dbo].[Appointment]
					(
					[LocalId]
					,[FirstName]
					,[LastName]
					,[FromTime]
					,[EndTime]
					,[Description]
					,[Doctor]
					,[ParentId]
					,[AppointmentType]
					,[CreatedDate]
					)
				VALUES
					(
					@LocalId
					,@FirstName
					,@LastName
					,@FromTime
					,@EndTime
					,@Description
					,@Doctor
					,@ParentId
					,@AppointmentType
					,@CreatedDate
					)
				
				-- Get the identity value
				SET @Id = SCOPE_IDENTITY()
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Appointment_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Updates a record in the Appointment table
-- Table Comment: Đặt lịch hẹn
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@LocalId" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@FirstName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@LastName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@FromTime" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@EndTime" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@Description" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault=""/>
				<parameter name="@Doctor" type="nvarchar" direction="Input" size="100" precision="0" scale="0" param="(100)" nulldefault=""/>
				<parameter name="@ParentId" type="varchar" direction="Input" size="15" precision="0" scale="0" param="(15)" nulldefault=""/>
				<parameter name="@AppointmentType" type="varchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[Appointment]
				SET
					[LocalId] = @LocalId
					,[FirstName] = @FirstName
					,[LastName] = @LastName
					,[FromTime] = @FromTime
					,[EndTime] = @EndTime
					,[Description] = @Description
					,[Doctor] = @Doctor
					,[ParentId] = @ParentId
					,[AppointmentType] = @AppointmentType
					,[CreatedDate] = @CreatedDate
				WHERE
[Id] = @Id 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Appointment_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Deletes a record in the Appointment table
-- Table Comment: Đặt lịch hẹn
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[Appointment] WITH (ROWLOCK) 
				WHERE
					[Id] = @Id
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Appointment_GetById" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Appointment table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[LocalId],
					[FirstName],
					[LastName],
					[FromTime],
					[EndTime],
					[Description],
					[Doctor],
					[ParentId],
					[AppointmentType],
					[CreatedDate]
				FROM
					[dbo].[Appointment]
				WHERE
					[Id] = @Id
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="Appointment_Find" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Finds records in the Appointment table passing nullable parameters
-- Table Comment: Đặt lịch hẹn
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@LocalId" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault="null"/>
				<parameter name="@FirstName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@LastName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@FromTime" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@EndTime" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@Description" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault="null"/>
				<parameter name="@Doctor" type="nvarchar" direction="Input" size="100" precision="0" scale="0" param="(100)" nulldefault="null"/>
				<parameter name="@ParentId" type="varchar" direction="Input" size="15" precision="0" scale="0" param="(15)" nulldefault="null"/>
				<parameter name="@AppointmentType" type="varchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault="null"/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [Id]
	, [LocalId]
	, [FirstName]
	, [LastName]
	, [FromTime]
	, [EndTime]
	, [Description]
	, [Doctor]
	, [ParentId]
	, [AppointmentType]
	, [CreatedDate]
    FROM
	[dbo].[Appointment]
    WHERE 
	 ([Id] = @Id OR @Id IS NULL)
	AND ([LocalId] = @LocalId OR @LocalId IS NULL)
	AND ([FirstName] = @FirstName OR @FirstName IS NULL)
	AND ([LastName] = @LastName OR @LastName IS NULL)
	AND ([FromTime] = @FromTime OR @FromTime IS NULL)
	AND ([EndTime] = @EndTime OR @EndTime IS NULL)
	AND ([Description] = @Description OR @Description IS NULL)
	AND ([Doctor] = @Doctor OR @Doctor IS NULL)
	AND ([ParentId] = @ParentId OR @ParentId IS NULL)
	AND ([AppointmentType] = @AppointmentType OR @AppointmentType IS NULL)
	AND ([CreatedDate] = @CreatedDate OR @CreatedDate IS NULL)
						
  END
  ELSE
  BEGIN
    SELECT
	  [Id]
	, [LocalId]
	, [FirstName]
	, [LastName]
	, [FromTime]
	, [EndTime]
	, [Description]
	, [Doctor]
	, [ParentId]
	, [AppointmentType]
	, [CreatedDate]
    FROM
	[dbo].[Appointment]
    WHERE 
	 ([Id] = @Id AND @Id is not null)
	OR ([LocalId] = @LocalId AND @LocalId is not null)
	OR ([FirstName] = @FirstName AND @FirstName is not null)
	OR ([LastName] = @LastName AND @LastName is not null)
	OR ([FromTime] = @FromTime AND @FromTime is not null)
	OR ([EndTime] = @EndTime AND @EndTime is not null)
	OR ([Description] = @Description AND @Description is not null)
	OR ([Doctor] = @Doctor AND @Doctor is not null)
	OR ([ParentId] = @ParentId AND @ParentId is not null)
	OR ([AppointmentType] = @AppointmentType AND @AppointmentType is not null)
	OR ([CreatedDate] = @CreatedDate AND @CreatedDate is not null)
	SELECT @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="Appointment_Find_Dynamic"  skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Appointment table using a dynamically generated query.
-- Table Comment: Đặt lịch hẹn
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				BEGIN
				
				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				INSERT INTO #PageIndex ( [Id] )
				SELECT TOP {3} [Id]
				FROM [dbo].[Appointment] {0}
				ORDER BY {1}
				
				-- Return paged results
				SELECT O.[Id], O.[LocalId], O.[FirstName], O.[LastName], O.[FromTime], O.[EndTime], O.[Description], O.[Doctor], O.[ParentId], O.[AppointmentType], O.[CreatedDate]
				FROM
				    [dbo].[Appointment] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > {2}
				    AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				

				-- get total count
				SELECT COUNT(*) AS TotalRowCount FROM [dbo].[Appointment] {0};
				
				DROP TABLE #PageIndex
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="Article_Get_List" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets all records from the Article table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				SELECT
					[Id],
					[LocalId],
					[Title],
					[Alias],
					[Summary],
					[Description],
					[MenuId],
					[Thumbnail],
					[IsPublished],
					[OrderIndex],
					[IsAllowDelete],
					[Language],
					[PublishedDate],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser],
					[IsHot]
				FROM
					[dbo].[Article]
					
				SELECT @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="Article_GetPaged" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Article table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				DECLARE @SQL AS nvarchar(4000)
				SET @SQL = 'INSERT INTO #PageIndex ([Id])'
				SET @SQL = @SQL + ' SELECT'
				SET @SQL = @SQL + ' [Id]'
				SET @SQL = @SQL + ' FROM [dbo].[Article]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				IF LEN(@OrderBy) > 0
				BEGIN
					SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				END
				
				-- Only get the number of rows needed here.
				SET ROWCOUNT @PageUpperBound
				
				-- Populate the temp table
				EXEC sp_executesql @SQL

				-- Reset Rowcount back to all
				SET ROWCOUNT 0
				
				-- Return paged results
				SELECT O.[Id], O.[LocalId], O.[Title], O.[Alias], O.[Summary], O.[Description], O.[MenuId], O.[Thumbnail], O.[IsPublished], O.[OrderIndex], O.[IsAllowDelete], O.[Language], O.[PublishedDate], O.[CreatedDate], O.[UpdatedDate], O.[CreatedUser], O.[UpdatedUser], O.[IsHot]
				FROM
				    [dbo].[Article] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > @PageLowerBound
					AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) AS TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[Article]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				EXEC sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="Article_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Inserts a record into the Article table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Output" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@LocalId" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@Alias" type="varchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@Summary" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault=""/>
				<parameter name="@Description" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@MenuId" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Thumbnail" type="varchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@IsPublished" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@IsAllowDelete" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@PublishedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@IsHot" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				INSERT INTO [dbo].[Article]
					(
					[LocalId]
					,[Title]
					,[Alias]
					,[Summary]
					,[Description]
					,[MenuId]
					,[Thumbnail]
					,[IsPublished]
					,[OrderIndex]
					,[IsAllowDelete]
					,[Language]
					,[PublishedDate]
					,[CreatedDate]
					,[UpdatedDate]
					,[CreatedUser]
					,[UpdatedUser]
					,[IsHot]
					)
				VALUES
					(
					@LocalId
					,@Title
					,@Alias
					,@Summary
					,@Description
					,@MenuId
					,@Thumbnail
					,@IsPublished
					,@OrderIndex
					,@IsAllowDelete
					,@Language
					,@PublishedDate
					,@CreatedDate
					,@UpdatedDate
					,@CreatedUser
					,@UpdatedUser
					,@IsHot
					)
				
				-- Get the identity value
				SET @Id = SCOPE_IDENTITY()
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Article_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Updates a record in the Article table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@LocalId" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@Alias" type="varchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@Summary" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault=""/>
				<parameter name="@Description" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@MenuId" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Thumbnail" type="varchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@IsPublished" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@IsAllowDelete" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@PublishedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@IsHot" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[Article]
				SET
					[LocalId] = @LocalId
					,[Title] = @Title
					,[Alias] = @Alias
					,[Summary] = @Summary
					,[Description] = @Description
					,[MenuId] = @MenuId
					,[Thumbnail] = @Thumbnail
					,[IsPublished] = @IsPublished
					,[OrderIndex] = @OrderIndex
					,[IsAllowDelete] = @IsAllowDelete
					,[Language] = @Language
					,[PublishedDate] = @PublishedDate
					,[CreatedDate] = @CreatedDate
					,[UpdatedDate] = @UpdatedDate
					,[CreatedUser] = @CreatedUser
					,[UpdatedUser] = @UpdatedUser
					,[IsHot] = @IsHot
				WHERE
[Id] = @Id 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Article_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Deletes a record in the Article table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[Article] WITH (ROWLOCK) 
				WHERE
					[Id] = @Id
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Article_GetByMenuId" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Article table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@MenuId" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				
				SELECT
					[Id],
					[LocalId],
					[Title],
					[Alias],
					[Summary],
					[Description],
					[MenuId],
					[Thumbnail],
					[IsPublished],
					[OrderIndex],
					[IsAllowDelete],
					[Language],
					[PublishedDate],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser],
					[IsHot]
				FROM
					[dbo].[Article]
				WHERE
					[MenuId] = @MenuId
				
				SELECT @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Article_GetByAlias" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Article table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Alias" type="varchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[LocalId],
					[Title],
					[Alias],
					[Summary],
					[Description],
					[MenuId],
					[Thumbnail],
					[IsPublished],
					[OrderIndex],
					[IsAllowDelete],
					[Language],
					[PublishedDate],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser],
					[IsHot]
				FROM
					[dbo].[Article]
				WHERE
					[Alias] = @Alias
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="Article_GetByLocalId" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Article table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@LocalId" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[LocalId],
					[Title],
					[Alias],
					[Summary],
					[Description],
					[MenuId],
					[Thumbnail],
					[IsPublished],
					[OrderIndex],
					[IsAllowDelete],
					[Language],
					[PublishedDate],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser],
					[IsHot]
				FROM
					[dbo].[Article]
				WHERE
					[LocalId] = @LocalId
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="Article_GetById" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Article table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[LocalId],
					[Title],
					[Alias],
					[Summary],
					[Description],
					[MenuId],
					[Thumbnail],
					[IsPublished],
					[OrderIndex],
					[IsAllowDelete],
					[Language],
					[PublishedDate],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser],
					[IsHot]
				FROM
					[dbo].[Article]
				WHERE
					[Id] = @Id
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="Article_Find" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Finds records in the Article table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@LocalId" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault="null"/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@Alias" type="varchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@Summary" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault="null"/>
				<parameter name="@Description" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@MenuId" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@Thumbnail" type="varchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@IsPublished" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@IsAllowDelete" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault="null"/>
				<parameter name="@PublishedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@IsHot" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [Id]
	, [LocalId]
	, [Title]
	, [Alias]
	, [Summary]
	, [Description]
	, [MenuId]
	, [Thumbnail]
	, [IsPublished]
	, [OrderIndex]
	, [IsAllowDelete]
	, [Language]
	, [PublishedDate]
	, [CreatedDate]
	, [UpdatedDate]
	, [CreatedUser]
	, [UpdatedUser]
	, [IsHot]
    FROM
	[dbo].[Article]
    WHERE 
	 ([Id] = @Id OR @Id IS NULL)
	AND ([LocalId] = @LocalId OR @LocalId IS NULL)
	AND ([Title] = @Title OR @Title IS NULL)
	AND ([Alias] = @Alias OR @Alias IS NULL)
	AND ([Summary] = @Summary OR @Summary IS NULL)
	AND ([MenuId] = @MenuId OR @MenuId IS NULL)
	AND ([Thumbnail] = @Thumbnail OR @Thumbnail IS NULL)
	AND ([IsPublished] = @IsPublished OR @IsPublished IS NULL)
	AND ([OrderIndex] = @OrderIndex OR @OrderIndex IS NULL)
	AND ([IsAllowDelete] = @IsAllowDelete OR @IsAllowDelete IS NULL)
	AND ([Language] = @Language OR @Language IS NULL)
	AND ([PublishedDate] = @PublishedDate OR @PublishedDate IS NULL)
	AND ([CreatedDate] = @CreatedDate OR @CreatedDate IS NULL)
	AND ([UpdatedDate] = @UpdatedDate OR @UpdatedDate IS NULL)
	AND ([CreatedUser] = @CreatedUser OR @CreatedUser IS NULL)
	AND ([UpdatedUser] = @UpdatedUser OR @UpdatedUser IS NULL)
	AND ([IsHot] = @IsHot OR @IsHot IS NULL)
						
  END
  ELSE
  BEGIN
    SELECT
	  [Id]
	, [LocalId]
	, [Title]
	, [Alias]
	, [Summary]
	, [Description]
	, [MenuId]
	, [Thumbnail]
	, [IsPublished]
	, [OrderIndex]
	, [IsAllowDelete]
	, [Language]
	, [PublishedDate]
	, [CreatedDate]
	, [UpdatedDate]
	, [CreatedUser]
	, [UpdatedUser]
	, [IsHot]
    FROM
	[dbo].[Article]
    WHERE 
	 ([Id] = @Id AND @Id is not null)
	OR ([LocalId] = @LocalId AND @LocalId is not null)
	OR ([Title] = @Title AND @Title is not null)
	OR ([Alias] = @Alias AND @Alias is not null)
	OR ([Summary] = @Summary AND @Summary is not null)
	OR ([MenuId] = @MenuId AND @MenuId is not null)
	OR ([Thumbnail] = @Thumbnail AND @Thumbnail is not null)
	OR ([IsPublished] = @IsPublished AND @IsPublished is not null)
	OR ([OrderIndex] = @OrderIndex AND @OrderIndex is not null)
	OR ([IsAllowDelete] = @IsAllowDelete AND @IsAllowDelete is not null)
	OR ([Language] = @Language AND @Language is not null)
	OR ([PublishedDate] = @PublishedDate AND @PublishedDate is not null)
	OR ([CreatedDate] = @CreatedDate AND @CreatedDate is not null)
	OR ([UpdatedDate] = @UpdatedDate AND @UpdatedDate is not null)
	OR ([CreatedUser] = @CreatedUser AND @CreatedUser is not null)
	OR ([UpdatedUser] = @UpdatedUser AND @UpdatedUser is not null)
	OR ([IsHot] = @IsHot AND @IsHot is not null)
	SELECT @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="Article_Find_Dynamic"  skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Article table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				BEGIN
				
				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				INSERT INTO #PageIndex ( [Id] )
				SELECT TOP {3} [Id]
				FROM [dbo].[Article] {0}
				ORDER BY {1}
				
				-- Return paged results
				SELECT O.[Id], O.[LocalId], O.[Title], O.[Alias], O.[Summary], O.[Description], O.[MenuId], O.[Thumbnail], O.[IsPublished], O.[OrderIndex], O.[IsAllowDelete], O.[Language], O.[PublishedDate], O.[CreatedDate], O.[UpdatedDate], O.[CreatedUser], O.[UpdatedUser], O.[IsHot]
				FROM
				    [dbo].[Article] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > {2}
				    AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				

				-- get total count
				SELECT COUNT(*) AS TotalRowCount FROM [dbo].[Article] {0};
				
				DROP TABLE #PageIndex
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="Contact_Get_List" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets all records from the Contact table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				SELECT
					[Id],
					[FullName],
					[Email],
					[Phone],
					[Description],
					[ContactType],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser],
					[IsRead]
				FROM
					[dbo].[Contact]
					
				SELECT @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="Contact_GetPaged" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Contact table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				DECLARE @SQL AS nvarchar(4000)
				SET @SQL = 'INSERT INTO #PageIndex ([Id])'
				SET @SQL = @SQL + ' SELECT'
				SET @SQL = @SQL + ' [Id]'
				SET @SQL = @SQL + ' FROM [dbo].[Contact]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				IF LEN(@OrderBy) > 0
				BEGIN
					SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				END
				
				-- Only get the number of rows needed here.
				SET ROWCOUNT @PageUpperBound
				
				-- Populate the temp table
				EXEC sp_executesql @SQL

				-- Reset Rowcount back to all
				SET ROWCOUNT 0
				
				-- Return paged results
				SELECT O.[Id], O.[FullName], O.[Email], O.[Phone], O.[Description], O.[ContactType], O.[CreatedDate], O.[UpdatedDate], O.[CreatedUser], O.[UpdatedUser], O.[IsRead]
				FROM
				    [dbo].[Contact] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > @PageLowerBound
					AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) AS TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[Contact]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				EXEC sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="Contact_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Inserts a record into the Contact table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Output" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@FullName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Phone" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@Description" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault=""/>
				<parameter name="@ContactType" type="varchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@IsRead" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				INSERT INTO [dbo].[Contact]
					(
					[FullName]
					,[Email]
					,[Phone]
					,[Description]
					,[ContactType]
					,[CreatedDate]
					,[UpdatedDate]
					,[CreatedUser]
					,[UpdatedUser]
					,[IsRead]
					)
				VALUES
					(
					@FullName
					,@Email
					,@Phone
					,@Description
					,@ContactType
					,@CreatedDate
					,@UpdatedDate
					,@CreatedUser
					,@UpdatedUser
					,@IsRead
					)
				
				-- Get the identity value
				SET @Id = SCOPE_IDENTITY()
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Contact_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Updates a record in the Contact table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@FullName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Phone" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@Description" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault=""/>
				<parameter name="@ContactType" type="varchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@IsRead" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[Contact]
				SET
					[FullName] = @FullName
					,[Email] = @Email
					,[Phone] = @Phone
					,[Description] = @Description
					,[ContactType] = @ContactType
					,[CreatedDate] = @CreatedDate
					,[UpdatedDate] = @UpdatedDate
					,[CreatedUser] = @CreatedUser
					,[UpdatedUser] = @UpdatedUser
					,[IsRead] = @IsRead
				WHERE
[Id] = @Id 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Contact_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Deletes a record in the Contact table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[Contact] WITH (ROWLOCK) 
				WHERE
					[Id] = @Id
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Contact_GetById" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Contact table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[FullName],
					[Email],
					[Phone],
					[Description],
					[ContactType],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser],
					[IsRead]
				FROM
					[dbo].[Contact]
				WHERE
					[Id] = @Id
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="Contact_Find" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Finds records in the Contact table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@FullName" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Phone" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault="null"/>
				<parameter name="@Description" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault="null"/>
				<parameter name="@ContactType" type="varchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault="null"/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@IsRead" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [Id]
	, [FullName]
	, [Email]
	, [Phone]
	, [Description]
	, [ContactType]
	, [CreatedDate]
	, [UpdatedDate]
	, [CreatedUser]
	, [UpdatedUser]
	, [IsRead]
    FROM
	[dbo].[Contact]
    WHERE 
	 ([Id] = @Id OR @Id IS NULL)
	AND ([FullName] = @FullName OR @FullName IS NULL)
	AND ([Email] = @Email OR @Email IS NULL)
	AND ([Phone] = @Phone OR @Phone IS NULL)
	AND ([Description] = @Description OR @Description IS NULL)
	AND ([ContactType] = @ContactType OR @ContactType IS NULL)
	AND ([CreatedDate] = @CreatedDate OR @CreatedDate IS NULL)
	AND ([UpdatedDate] = @UpdatedDate OR @UpdatedDate IS NULL)
	AND ([CreatedUser] = @CreatedUser OR @CreatedUser IS NULL)
	AND ([UpdatedUser] = @UpdatedUser OR @UpdatedUser IS NULL)
	AND ([IsRead] = @IsRead OR @IsRead IS NULL)
						
  END
  ELSE
  BEGIN
    SELECT
	  [Id]
	, [FullName]
	, [Email]
	, [Phone]
	, [Description]
	, [ContactType]
	, [CreatedDate]
	, [UpdatedDate]
	, [CreatedUser]
	, [UpdatedUser]
	, [IsRead]
    FROM
	[dbo].[Contact]
    WHERE 
	 ([Id] = @Id AND @Id is not null)
	OR ([FullName] = @FullName AND @FullName is not null)
	OR ([Email] = @Email AND @Email is not null)
	OR ([Phone] = @Phone AND @Phone is not null)
	OR ([Description] = @Description AND @Description is not null)
	OR ([ContactType] = @ContactType AND @ContactType is not null)
	OR ([CreatedDate] = @CreatedDate AND @CreatedDate is not null)
	OR ([UpdatedDate] = @UpdatedDate AND @UpdatedDate is not null)
	OR ([CreatedUser] = @CreatedUser AND @CreatedUser is not null)
	OR ([UpdatedUser] = @UpdatedUser AND @UpdatedUser is not null)
	OR ([IsRead] = @IsRead AND @IsRead is not null)
	SELECT @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="Contact_Find_Dynamic"  skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Contact table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				BEGIN
				
				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				INSERT INTO #PageIndex ( [Id] )
				SELECT TOP {3} [Id]
				FROM [dbo].[Contact] {0}
				ORDER BY {1}
				
				-- Return paged results
				SELECT O.[Id], O.[FullName], O.[Email], O.[Phone], O.[Description], O.[ContactType], O.[CreatedDate], O.[UpdatedDate], O.[CreatedUser], O.[UpdatedUser], O.[IsRead]
				FROM
				    [dbo].[Contact] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > {2}
				    AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				

				-- get total count
				SELECT COUNT(*) AS TotalRowCount FROM [dbo].[Contact] {0};
				
				DROP TABLE #PageIndex
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="Faq_Get_List" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets all records from the Faq table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				SELECT
					[Id],
					[FullName],
					[Email],
					[Title],
					[Question],
					[Answer],
					[IsPublished],
					[ClientIp],
					[IsHot],
					[OrderIndex],
					[Language],
					[AnsweredDate],
					[AnsweredUser],
					[CreatedDate],
					[UpdatedDate]
				FROM
					[dbo].[Faq]
					
				SELECT @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="Faq_GetPaged" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Faq table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				DECLARE @SQL AS nvarchar(4000)
				SET @SQL = 'INSERT INTO #PageIndex ([Id])'
				SET @SQL = @SQL + ' SELECT'
				SET @SQL = @SQL + ' [Id]'
				SET @SQL = @SQL + ' FROM [dbo].[Faq]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				IF LEN(@OrderBy) > 0
				BEGIN
					SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				END
				
				-- Only get the number of rows needed here.
				SET ROWCOUNT @PageUpperBound
				
				-- Populate the temp table
				EXEC sp_executesql @SQL

				-- Reset Rowcount back to all
				SET ROWCOUNT 0
				
				-- Return paged results
				SELECT O.[Id], O.[FullName], O.[Email], O.[Title], O.[Question], O.[Answer], O.[IsPublished], O.[ClientIp], O.[IsHot], O.[OrderIndex], O.[Language], O.[AnsweredDate], O.[AnsweredUser], O.[CreatedDate], O.[UpdatedDate]
				FROM
				    [dbo].[Faq] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > @PageLowerBound
					AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) AS TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[Faq]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				EXEC sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="Faq_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Inserts a record into the Faq table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Output" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@FullName" type="nvarchar" direction="Input" size="100" precision="0" scale="0" param="(100)" nulldefault=""/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Question" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault=""/>
				<parameter name="@Answer" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault=""/>
				<parameter name="@IsPublished" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ClientIp" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@IsHot" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@AnsweredDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@AnsweredUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				INSERT INTO [dbo].[Faq]
					(
					[FullName]
					,[Email]
					,[Title]
					,[Question]
					,[Answer]
					,[IsPublished]
					,[ClientIp]
					,[IsHot]
					,[OrderIndex]
					,[Language]
					,[AnsweredDate]
					,[AnsweredUser]
					,[CreatedDate]
					,[UpdatedDate]
					)
				VALUES
					(
					@FullName
					,@Email
					,@Title
					,@Question
					,@Answer
					,@IsPublished
					,@ClientIp
					,@IsHot
					,@OrderIndex
					,@Language
					,@AnsweredDate
					,@AnsweredUser
					,@CreatedDate
					,@UpdatedDate
					)
				
				-- Get the identity value
				SET @Id = SCOPE_IDENTITY()
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Faq_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Updates a record in the Faq table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@FullName" type="nvarchar" direction="Input" size="100" precision="0" scale="0" param="(100)" nulldefault=""/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Question" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault=""/>
				<parameter name="@Answer" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault=""/>
				<parameter name="@IsPublished" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ClientIp" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@IsHot" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@AnsweredDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@AnsweredUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[Faq]
				SET
					[FullName] = @FullName
					,[Email] = @Email
					,[Title] = @Title
					,[Question] = @Question
					,[Answer] = @Answer
					,[IsPublished] = @IsPublished
					,[ClientIp] = @ClientIp
					,[IsHot] = @IsHot
					,[OrderIndex] = @OrderIndex
					,[Language] = @Language
					,[AnsweredDate] = @AnsweredDate
					,[AnsweredUser] = @AnsweredUser
					,[CreatedDate] = @CreatedDate
					,[UpdatedDate] = @UpdatedDate
				WHERE
[Id] = @Id 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Faq_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Deletes a record in the Faq table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[Faq] WITH (ROWLOCK) 
				WHERE
					[Id] = @Id
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="Faq_GetById" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the Faq table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[FullName],
					[Email],
					[Title],
					[Question],
					[Answer],
					[IsPublished],
					[ClientIp],
					[IsHot],
					[OrderIndex],
					[Language],
					[AnsweredDate],
					[AnsweredUser],
					[CreatedDate],
					[UpdatedDate]
				FROM
					[dbo].[Faq]
				WHERE
					[Id] = @Id
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="Faq_Find" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Finds records in the Faq table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@FullName" type="nvarchar" direction="Input" size="100" precision="0" scale="0" param="(100)" nulldefault="null"/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Question" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault="null"/>
				<parameter name="@Answer" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault="null"/>
				<parameter name="@IsPublished" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@ClientIp" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault="null"/>
				<parameter name="@IsHot" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@Language" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault="null"/>
				<parameter name="@AnsweredDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@AnsweredUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [Id]
	, [FullName]
	, [Email]
	, [Title]
	, [Question]
	, [Answer]
	, [IsPublished]
	, [ClientIp]
	, [IsHot]
	, [OrderIndex]
	, [Language]
	, [AnsweredDate]
	, [AnsweredUser]
	, [CreatedDate]
	, [UpdatedDate]
    FROM
	[dbo].[Faq]
    WHERE 
	 ([Id] = @Id OR @Id IS NULL)
	AND ([FullName] = @FullName OR @FullName IS NULL)
	AND ([Email] = @Email OR @Email IS NULL)
	AND ([Title] = @Title OR @Title IS NULL)
	AND ([Question] = @Question OR @Question IS NULL)
	AND ([Answer] = @Answer OR @Answer IS NULL)
	AND ([IsPublished] = @IsPublished OR @IsPublished IS NULL)
	AND ([ClientIp] = @ClientIp OR @ClientIp IS NULL)
	AND ([IsHot] = @IsHot OR @IsHot IS NULL)
	AND ([OrderIndex] = @OrderIndex OR @OrderIndex IS NULL)
	AND ([Language] = @Language OR @Language IS NULL)
	AND ([AnsweredDate] = @AnsweredDate OR @AnsweredDate IS NULL)
	AND ([AnsweredUser] = @AnsweredUser OR @AnsweredUser IS NULL)
	AND ([CreatedDate] = @CreatedDate OR @CreatedDate IS NULL)
	AND ([UpdatedDate] = @UpdatedDate OR @UpdatedDate IS NULL)
						
  END
  ELSE
  BEGIN
    SELECT
	  [Id]
	, [FullName]
	, [Email]
	, [Title]
	, [Question]
	, [Answer]
	, [IsPublished]
	, [ClientIp]
	, [IsHot]
	, [OrderIndex]
	, [Language]
	, [AnsweredDate]
	, [AnsweredUser]
	, [CreatedDate]
	, [UpdatedDate]
    FROM
	[dbo].[Faq]
    WHERE 
	 ([Id] = @Id AND @Id is not null)
	OR ([FullName] = @FullName AND @FullName is not null)
	OR ([Email] = @Email AND @Email is not null)
	OR ([Title] = @Title AND @Title is not null)
	OR ([Question] = @Question AND @Question is not null)
	OR ([Answer] = @Answer AND @Answer is not null)
	OR ([IsPublished] = @IsPublished AND @IsPublished is not null)
	OR ([ClientIp] = @ClientIp AND @ClientIp is not null)
	OR ([IsHot] = @IsHot AND @IsHot is not null)
	OR ([OrderIndex] = @OrderIndex AND @OrderIndex is not null)
	OR ([Language] = @Language AND @Language is not null)
	OR ([AnsweredDate] = @AnsweredDate AND @AnsweredDate is not null)
	OR ([AnsweredUser] = @AnsweredUser AND @AnsweredUser is not null)
	OR ([CreatedDate] = @CreatedDate AND @CreatedDate is not null)
	OR ([UpdatedDate] = @UpdatedDate AND @UpdatedDate is not null)
	SELECT @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="Faq_Find_Dynamic"  skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the Faq table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				BEGIN
				
				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				INSERT INTO #PageIndex ( [Id] )
				SELECT TOP {3} [Id]
				FROM [dbo].[Faq] {0}
				ORDER BY {1}
				
				-- Return paged results
				SELECT O.[Id], O.[FullName], O.[Email], O.[Title], O.[Question], O.[Answer], O.[IsPublished], O.[ClientIp], O.[IsHot], O.[OrderIndex], O.[Language], O.[AnsweredDate], O.[AnsweredUser], O.[CreatedDate], O.[UpdatedDate]
				FROM
				    [dbo].[Faq] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > {2}
				    AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				

				-- get total count
				SELECT COUNT(*) AS TotalRowCount FROM [dbo].[Faq] {0};
				
				DROP TABLE #PageIndex
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="File_Get_List" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets all records from the File table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				SELECT
					[Id],
					[Url],
					[Title],
					[ParentId],
					[OrderIndex],
					[IsPublished],
					[FileType],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser],
					[Catalog]
				FROM
					[dbo].[File]
					
				SELECT @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="File_GetPaged" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the File table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				DECLARE @SQL AS nvarchar(4000)
				SET @SQL = 'INSERT INTO #PageIndex ([Id])'
				SET @SQL = @SQL + ' SELECT'
				SET @SQL = @SQL + ' [Id]'
				SET @SQL = @SQL + ' FROM [dbo].[File]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				IF LEN(@OrderBy) > 0
				BEGIN
					SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				END
				
				-- Only get the number of rows needed here.
				SET ROWCOUNT @PageUpperBound
				
				-- Populate the temp table
				EXEC sp_executesql @SQL

				-- Reset Rowcount back to all
				SET ROWCOUNT 0
				
				-- Return paged results
				SELECT O.[Id], O.[Url], O.[Title], O.[ParentId], O.[OrderIndex], O.[IsPublished], O.[FileType], O.[CreatedDate], O.[UpdatedDate], O.[CreatedUser], O.[UpdatedUser], O.[Catalog]
				FROM
				    [dbo].[File] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > @PageLowerBound
					AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) AS TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[File]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				EXEC sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="File_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Inserts a record into the File table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Output" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Url" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@ParentId" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@IsPublished" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@FileType" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Catalog" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				INSERT INTO [dbo].[File]
					(
					[Url]
					,[Title]
					,[ParentId]
					,[OrderIndex]
					,[IsPublished]
					,[FileType]
					,[CreatedDate]
					,[UpdatedDate]
					,[CreatedUser]
					,[UpdatedUser]
					,[Catalog]
					)
				VALUES
					(
					@Url
					,@Title
					,@ParentId
					,@OrderIndex
					,@IsPublished
					,@FileType
					,@CreatedDate
					,@UpdatedDate
					,@CreatedUser
					,@UpdatedUser
					,@Catalog
					)
				
				-- Get the identity value
				SET @Id = SCOPE_IDENTITY()
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="File_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Updates a record in the File table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Url" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@ParentId" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@IsPublished" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@FileType" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault=""/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Catalog" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[File]
				SET
					[Url] = @Url
					,[Title] = @Title
					,[ParentId] = @ParentId
					,[OrderIndex] = @OrderIndex
					,[IsPublished] = @IsPublished
					,[FileType] = @FileType
					,[CreatedDate] = @CreatedDate
					,[UpdatedDate] = @UpdatedDate
					,[CreatedUser] = @CreatedUser
					,[UpdatedUser] = @UpdatedUser
					,[Catalog] = @Catalog
				WHERE
[Id] = @Id 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="File_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Deletes a record in the File table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[File] WITH (ROWLOCK) 
				WHERE
					[Id] = @Id
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="File_GetById" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the File table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[Url],
					[Title],
					[ParentId],
					[OrderIndex],
					[IsPublished],
					[FileType],
					[CreatedDate],
					[UpdatedDate],
					[CreatedUser],
					[UpdatedUser],
					[Catalog]
				FROM
					[dbo].[File]
				WHERE
					[Id] = @Id
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="File_Find" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Finds records in the File table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@Url" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@ParentId" type="nvarchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault="null"/>
				<parameter name="@OrderIndex" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@IsPublished" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@FileType" type="varchar" direction="Input" size="10" precision="0" scale="0" param="(10)" nulldefault="null"/>
				<parameter name="@CreatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@UpdatedDate" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@CreatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@UpdatedUser" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Catalog" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [Id]
	, [Url]
	, [Title]
	, [ParentId]
	, [OrderIndex]
	, [IsPublished]
	, [FileType]
	, [CreatedDate]
	, [UpdatedDate]
	, [CreatedUser]
	, [UpdatedUser]
	, [Catalog]
    FROM
	[dbo].[File]
    WHERE 
	 ([Id] = @Id OR @Id IS NULL)
	AND ([Url] = @Url OR @Url IS NULL)
	AND ([Title] = @Title OR @Title IS NULL)
	AND ([ParentId] = @ParentId OR @ParentId IS NULL)
	AND ([OrderIndex] = @OrderIndex OR @OrderIndex IS NULL)
	AND ([IsPublished] = @IsPublished OR @IsPublished IS NULL)
	AND ([FileType] = @FileType OR @FileType IS NULL)
	AND ([CreatedDate] = @CreatedDate OR @CreatedDate IS NULL)
	AND ([UpdatedDate] = @UpdatedDate OR @UpdatedDate IS NULL)
	AND ([CreatedUser] = @CreatedUser OR @CreatedUser IS NULL)
	AND ([UpdatedUser] = @UpdatedUser OR @UpdatedUser IS NULL)
	AND ([Catalog] = @Catalog OR @Catalog IS NULL)
						
  END
  ELSE
  BEGIN
    SELECT
	  [Id]
	, [Url]
	, [Title]
	, [ParentId]
	, [OrderIndex]
	, [IsPublished]
	, [FileType]
	, [CreatedDate]
	, [UpdatedDate]
	, [CreatedUser]
	, [UpdatedUser]
	, [Catalog]
    FROM
	[dbo].[File]
    WHERE 
	 ([Id] = @Id AND @Id is not null)
	OR ([Url] = @Url AND @Url is not null)
	OR ([Title] = @Title AND @Title is not null)
	OR ([ParentId] = @ParentId AND @ParentId is not null)
	OR ([OrderIndex] = @OrderIndex AND @OrderIndex is not null)
	OR ([IsPublished] = @IsPublished AND @IsPublished is not null)
	OR ([FileType] = @FileType AND @FileType is not null)
	OR ([CreatedDate] = @CreatedDate AND @CreatedDate is not null)
	OR ([UpdatedDate] = @UpdatedDate AND @UpdatedDate is not null)
	OR ([CreatedUser] = @CreatedUser AND @CreatedUser is not null)
	OR ([UpdatedUser] = @UpdatedUser AND @UpdatedUser is not null)
	OR ([Catalog] = @Catalog AND @Catalog is not null)
	SELECT @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="File_Find_Dynamic"  skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the File table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				BEGIN
				
				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				INSERT INTO #PageIndex ( [Id] )
				SELECT TOP {3} [Id]
				FROM [dbo].[File] {0}
				ORDER BY {1}
				
				-- Return paged results
				SELECT O.[Id], O.[Url], O.[Title], O.[ParentId], O.[OrderIndex], O.[IsPublished], O.[FileType], O.[CreatedDate], O.[UpdatedDate], O.[CreatedUser], O.[UpdatedUser], O.[Catalog]
				FROM
				    [dbo].[File] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > {2}
				    AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				

				-- get total count
				SELECT COUNT(*) AS TotalRowCount FROM [dbo].[File] {0};
				
				DROP TABLE #PageIndex
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="UserType_Get_List" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets all records from the UserType table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				SELECT
					[Id],
					[Title]
				FROM
					[dbo].[UserType]
					
				SELECT @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="UserType_GetPaged" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the UserType table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				DECLARE @SQL AS nvarchar(4000)
				SET @SQL = 'INSERT INTO #PageIndex ([Id])'
				SET @SQL = @SQL + ' SELECT'
				SET @SQL = @SQL + ' [Id]'
				SET @SQL = @SQL + ' FROM [dbo].[UserType]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				IF LEN(@OrderBy) > 0
				BEGIN
					SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				END
				
				-- Only get the number of rows needed here.
				SET ROWCOUNT @PageUpperBound
				
				-- Populate the temp table
				EXEC sp_executesql @SQL

				-- Reset Rowcount back to all
				SET ROWCOUNT 0
				
				-- Return paged results
				SELECT O.[Id], O.[Title]
				FROM
				    [dbo].[UserType] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > @PageLowerBound
					AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) AS TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[UserType]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				EXEC sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="UserType_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Inserts a record into the UserType table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				INSERT INTO [dbo].[UserType]
					(
					[Id]
					,[Title]
					)
				VALUES
					(
					@Id
					,@Title
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="UserType_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Updates a record in the UserType table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalId" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[UserType]
				SET
					[Id] = @Id
					,[Title] = @Title
				WHERE
[Id] = @OriginalId 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="UserType_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Deletes a record in the UserType table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[UserType] WITH (ROWLOCK) 
				WHERE
					[Id] = @Id
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="UserType_GetById" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Select records from the UserType table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[Id],
					[Title]
				FROM
					[dbo].[UserType]
				WHERE
					[Id] = @Id
				SELECT @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="UserType_Find" >
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Finds records in the UserType table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Id" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [Id]
	, [Title]
    FROM
	[dbo].[UserType]
    WHERE 
	 ([Id] = @Id OR @Id IS NULL)
	AND ([Title] = @Title OR @Title IS NULL)
						
  END
  ELSE
  BEGIN
    SELECT
	  [Id]
	, [Title]
    FROM
	[dbo].[UserType]
    WHERE 
	 ([Id] = @Id AND @Id is not null)
	OR ([Title] = @Title AND @Title is not null)
	SELECT @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="UserType_Find_Dynamic"  skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------

-- Created By:  ()
-- Purpose: Gets records from the UserType table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				
				BEGIN
				
				-- Create a temp table to store the select results
				CREATE TABLE #PageIndex
				(
				    [IndexId] int IDENTITY (1, 1) NOT NULL,
				    [Id] int 
				)
				
				-- Insert into the temp table
				INSERT INTO #PageIndex ( [Id] )
				SELECT TOP {3} [Id]
				FROM [dbo].[UserType] {0}
				ORDER BY {1}
				
				-- Return paged results
				SELECT O.[Id], O.[Title]
				FROM
				    [dbo].[UserType] O,
				    #PageIndex PageIndex
				WHERE
				    PageIndex.IndexId > {2}
				    AND O.[Id] = PageIndex.[Id]
				ORDER BY
				    PageIndex.IndexId
				

				-- get total count
				SELECT COUNT(*) AS TotalRowCount FROM [dbo].[UserType] {0};
				
				DROP TABLE #PageIndex
				END
			]]></body>
		</procedure>
		
</procedures>
</root>
